package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;

/**
 * @Author: Miyako
 * @Date: 2024-07-13-17:33
 * @Description:
 */
public class CollectionToArrayDemo {
    public static void main(String[] args) {
        Collection<Integer> a = new ArrayList<>();
        int [] SS = {1,2,3,4,5,6,7,8,9};
        int sum =Arrays.stream(SS).sum();
        System.out.println(sum);
        for (int i= 0 ; i<9;i++){
            a.add(i);
        }
        System.out.println(a);
        Object[] sss = a.toArray();
        for (Object x : sss){
            System.out.print((int)x);
        }
        System.out.println(Arrays.toString(sss));
        Integer [] ss= a.toArray(new Integer[a.size()]);//新建数组对象里的长度可以设置为比集合少，集合判断这个数组装不下会自己新建一个对象。
        System.out.println(Arrays.toString(ss));


    }
}
